﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Users_UserCenter : System.Web.UI.Page
{
    protected void Page_PreInit(object sender, EventArgs e)
    {
        Page.Theme = BLL.Common.GetWSThemes();
    }
    DataSet ds = new DataSet();
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = BasePage.WebTitle;
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            ds = new BLL.V_CUSTOMER().UserCenterIndexInfo(BasePage.GetValue(0));
            if (ds != null)
            {
                Init_logininfo(ds.Tables[0]);
                Init_Ordersl(ds.Tables[1]);
                Init_address(ds.Tables[2]);
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
    private void Init_logininfo(DataTable dt)
    {
        if (dt.Rows.Count > 0)
        {
            realName.Text = dt.Rows[0]["BYZD5"].ToString();
            logintime.Text = dt.Rows[0]["VC_LASTLOGINTIME"] == DBNull.Value ? "" : dt.Rows[0]["VC_LASTLOGINTIME"].ToString();
            loginname.Text = dt.Rows[0]["DM"].ToString();
            jifeng.Text = dt.Rows[0]["DQJF"] == DBNull.Value ? "0" : dt.Rows[0]["DQJF"].ToString();
            email.Text = dt.Rows[0]["EMAIL"].ToString();
            reallyname.Text = dt.Rows[0]["GKMC"] == DBNull.Value ? "" : dt.Rows[0]["GKMC"].ToString();
            accountmoney.Text = dt.Rows[0]["DQJE"] == DBNull.Value ? "" : string.Format("{0:F}", dt.Rows[0]["DQJE"]);
            accountzk.Text = dt.Rows[0]["ZK"] == DBNull.Value ? "" : string.Format("{0:F}", dt.Rows[0]["ZK"]);
            accountcardtype.Text = dt.Rows[0]["KMC"] == DBNull.Value ? "" : dt.Rows[0]["KMC"].ToString();
            pwdquetion.Text = dt.Rows[0]["VC_PWDQUESTION"] == DBNull.Value ? "" : dt.Rows[0]["VC_PWDQUESTION"].ToString();
            pwdanswer.Text = dt.Rows[0]["VC_PWDANSWER"] == DBNull.Value ? "未设置" : "已设置";
        }
    }
    private void Init_address(DataTable dt)
    {
        if (dt.Rows.Count > 0)
        {
            Repeater1.DataSource = dt;
            Repeater1.DataBind();
        }
    }
    private void Init_Ordersl(DataTable dt)
    {
        if (dt.Rows.Count > 0)
        {
            jiaoyi.Text = dt.Rows[0]["ORDERCOUNT"] == DBNull.Value ? "0" : dt.Rows[0]["ORDERCOUNT"].ToString();
            tuihuo.Text = "0";
        }
    }
}
